package com.sgb.kjwl.view.ui.activity.self.lease;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.sgb.kjwl.AppActivity;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ActivitySelfLeaseDemandListBinding;
import com.sgb.kjwl.databinding.ActivitySelfLeaseOrderListBinding;
import com.sgb.kjwl.view.ui.fragment.self.LeaseDemandStateFragment;
import com.sgb.kjwl.view.ui.fragment.self.LeaseOrderStateFragment;
import com.swgk.core.base.di.AppComponent;
import com.swgk.core.recyclerview.adapter.SlidingFragmentPagerAdapter;

import java.util.ArrayList;

/**
 * 快捷需求列表
 */
public class SelfLeaseDemandListActivity extends AppActivity {
    private ActivitySelfLeaseDemandListBinding binding;
    private String[] titles = {"全部", "待处理", "处理中", "已结束"};
    private ArrayList<Fragment> mFragments;

    public static void start(Context context) {
        start(context, null);
    }

    public static void start(Context context, Intent extras) {
        Intent intent = new Intent();
        intent.setClass(context, SelfLeaseDemandListActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
        if (extras != null) {
            intent.putExtras(extras);
        }
        context.startActivity(intent);
    }

    @Override
    protected void initView() {
        binding = DataBindingUtil.setContentView(SelfLeaseDemandListActivity.this, R.layout.activity_self_lease_demand_list);
        binding.topLayout.ivBack.setOnClickListener(v -> finish());
    }

    @Override
    protected void init() {
        binding.topLayout.titleView.setText("快捷需求");
        //订单状态status 1待接单,2 待确认,3待付款，4支付中，5待运输，6待验收,7已完成,8已取消 ,9已拒绝,全部为空
        mFragments = new ArrayList<Fragment>();
        mFragments.add(LeaseDemandStateFragment.newInstance(""));//全部
        mFragments.add(LeaseDemandStateFragment.newInstance("0"));
        mFragments.add(LeaseDemandStateFragment.newInstance("1"));
        mFragments.add(LeaseDemandStateFragment.newInstance("2"));
        SlidingFragmentPagerAdapter mAdapetr = new SlidingFragmentPagerAdapter(getSupportFragmentManager(), mFragments, titles);
        binding.viewpager.setAdapter(mAdapetr);
        binding.viewpager.setOffscreenPageLimit(1);
        binding.tablayout.setupWithViewPager(binding.viewpager);
    }

}

